<?php

class Application_Model_User {
	
	protected $id_user;
	protected $first_name;
	protected $last_name;
	protected $email;
	protected $password;
	protected $password_salt;
	protected $address;
	protected $is_admin;
	protected $id_cart;
	
	public function __construct(array $options = null){
		if (is_array($options)) {
			$this->setOptions($options);
		}
	}
	
	public function __set($name, $value){
		$method = 'set' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid user property');
		}
		$this->$method($value);
	}
	
	public function __get($name){
		$method = 'get' . $name;
		if (('mapper' == $name) || !method_exists($this, $method)) {
			throw new Exception('Invalid user property');
		}
		return $this->$method();
	}
	
	public function setOptions(array $options){
		$methods = get_class_methods($this);
		foreach ($options as $key => $value) {
			$method = 'set' . ucfirst($key);
			if (in_array($method, $methods)) {
				$this->$method($value);
			}
		}
		return $this;
	}
	
	public function setId_user($id){
		$this->id_user = (int) $id;
		return $this;
	}
	
	public function getId_user(){
		return $this->id_user;
	}
	
	public function setFirst_name($text){
		$this->first_name = (string) $text;
		return $this;
	}
	
	public function getFirst_name(){
		return $this->first_name;
	}
	
	public function setLast_name($text){
		$this->last_name = (string) $text;
		return $this;
	}
	
	public function getLast_name(){
		return $this->last_name;
	}
	
	public function setEmail($email){
		$this->email = (string) $email;
		return $this;
	}
	
	public function getEmail(){
		return $this->email;
	}
	
	public function setPassword($password){
		$this->password = (string) $password;
		return $this;
	}
	
	public function getPassword(){
		return $this->password;
	}
	
	public function setPassword_salt($password_salt){
		$this->password_salt = (string) $password_salt;
		return $this;
	}
	
	public function getPassword_salt(){
		return $this->password_salt;
	}
	
	public function setAddress($address){
		$this->address = (string) $address;
		return $this;
	}
	
	public function getAddress(){
		return $this->address;
	}
	
	public function setIs_admin($isAdmin){
		$this->is_admin = (int) $isAdmin;
		return $this;
	}
	
	public function getIs_admin(){
		return $this->is_admin;
	}
	
	public function setId_cart($id_cart){
		$this->id_cart = (int) $id_cart;
		return $this;
	}
	
	public function getId_cart(){
		return $this->id_cart;
	}

}

